<?php
/** 
 * EGP Framework
 *
 * LICENSE
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author     Akon(番茄红了) <aultoale@gmail.com>
 * @copyright  Copyright (c) 2008 (http://www.tblog.com.cn)
 * @license    http://www.gnu.org/licenses/gpl.html     GPL 3
 */

!defined('EGP_LIB_DIR') && die('Access Deny!');

/**
 * Feedback (信息反馈)
 *
 * @package    helper
 * @author     Akon(番茄红了) <aultoale@gmail.com>
 * @copyright  Copyright (c) 2008 (http://www.tblog.com.cn)
 * @license    http://www.gnu.org/licenses/gpl.html     GPL 3
 */
class EGP_View_Helper_Feedback extends EGP_View_Helper_Abstract
{

    /**
     * 初始化
     *
     * @param  array    $params      参数
     * @param  boolean  $autoRender  自动加载 VIEW 页面
     * @param  boolean  $autoExit    自动退出
     * @return EGP_View_Helper_Feedback
     */
    public function init(array $params = array(), $autoRender = true, $autoExit = true)
    {
        $this->view->assign($params);
        true === $autoRender && $this->render(null, $autoExit);
        return $this;
    }

    /**
     * 加载 VIEW 页面
     *
     * @param  string   $template  模板文件名称
     * @param  boolean  $autoExit  自动退出
     */
    public function render($template = null, $autoExit = true)
    {
        if (null === $template && isset($this->view->template)) {
            $template = $this->view->template;
            unset($this->view->template);
        } else {
            $template = 'feedback';
        }
        !isset($this->view->title)    && $this->view->title    = '信息反馈';
        !isset($this->view->message)  && $this->view->message  = '';
        !isset($this->view->redirect) && $this->view->redirect = 'javascript:history.back();';
        !isset($this->view->linktext) && $this->view->linktext = '返回上一页';
        !isset($this->view->refresh)  && $this->view->refresh  = 5;
        $this->view->render($template);
        true === $autoExit && exit(0);
    }

}